/**
 * 
 */
package com.thor.palmmall.rest.chart.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.chart.AOrdinarySalesType;
import com.thor.palmmall.spi.chart.SOrdinarySalesType;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class AOrdinarySalesTypeConverter
    implements Converter<SOrdinarySalesType, AOrdinarySalesType> {

  public static AOrdinarySalesTypeConverter getInstance() {
    if (instance == null)
      instance = new AOrdinarySalesTypeConverter();
    return instance;
  }

  private static AOrdinarySalesTypeConverter instance;

  private AOrdinarySalesTypeConverter() {
  }

  @Override
  public AOrdinarySalesType convert(SOrdinarySalesType source) {
    if (source == null) {
      return null;
    }
    AOrdinarySalesType target = new AOrdinarySalesType();
    target.setCalcUnit(source.getCalcUnit());
    target.setCompLastMonthRate(source.getCompLastMonthRate());
    target.setCompLastWeekRate(source.getCompLastWeekRate());
    target.setCompLastYearRate(source.getCompLastYearRate());
    target.setSalePerArea(source.getSalePerArea());
    target.setSales(source.getSales());
    target.setStores(ConverterUtil.convert(source.getStores(), ASalesStoreConverter.getInstance()));
    return target;
  }

}
